{% extends 'base.html' %}
{% load rbac %}
{% block content %}
    <div class="container">
        <div class="row">
            <div class="col-md-8 ">
                <form action="?type=add" method="post">
                    {% csrf_token %}
                    {{ add_formset.management_form }}
                     <div class="panel panel-default">
                    <div class=" panel-heading "><span class="glyphicon glyphicon-list"></span>&nbsp;待新建的权限列表
                        <button
                           class="btn btn-primary glyphicon glyphicon-plus pull-right"
                           style="margin-top: -8px;font-size: 8px">添加</button>
                    </div>
                    <table class="table">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>名称</th>
                            <th>URL</th>
                            <th>URL别名</th>
                            <th>菜单</th>
                            <th>父权限</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for form in add_formset %}
                            <tr>
                                <td>{{ forloop.counter }}</td>
                                {% for filed in form %}
                                    <td>{{ filed }} <span style="color: red">{{ filed.errors.0 }}</span></td>
                                {% endfor %}
                            </tr>
                        {% endfor %}

                        </tbody>
                    </table>
                </div>
                </form>
                <div class="panel panel-warning">
                    <div class=" panel-heading "><span class="glyphicon glyphicon-calendar"></span>&nbsp;待删除的权限列表
                    </div>
                    <table class="table">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>名称</th>
                            <th>URL</th>
                            <th>URL别名</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for del_item in del_item_list %}
                            <tr>
                                <th>{{ forloop.counter }}</th>
                                <th>{{ del_item.title }}</th>
                                <th>{{ del_item.url }}</th>
                                <th>{{ del_item.alias }}</th>
                                <th><a href="/rbac/multi/permissions/del/{{ del_item.id }}/" class="glyphicon glyphicon-trash " style="color: red"></a></th>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </div>

                <form action="?type=update" method="post">
                    {% csrf_token %}
                    {{ update_formset.management_form }}
                    <div class="panel panel-success">
                    <div class=" panel-heading "><span class="glyphicon glyphicon-edit"></span>&nbsp;待更新的权限列表
                        <button
                           class="btn btn-success  pull-right"
                           style="margin-top: -8px;font-size: 8px"><span class="glyphicon glyphicon-list-alt"></span>&nbsp;保存</button>
                    </div>
                    <table class="table">
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>名称</th>
                            <th>URL</th>
                            <th>URL别名</th>
                            <th>菜单</th>
                            <th>父权限</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for form in update_formset %}
                            <tr>
                                <td>{{ forloop.counter }}</td>
                                {% for filed in form %}
                                    {% if forloop.first %}
                                        {{ filed }}
                                    {% else %}
                                        <td>{{ filed }} <span>{{ filed.errors.0 }}</span></td>
                                    {% endif %}
                                {% endfor %}
                            </tr>
                        {% endfor %}

                        </tbody>
                    </table>
                </div>
                </form>
            </div>
        </div>
    </div>
{% endblock content %}